package com.qf.hospital.system.util;

import com.qf.hospital.system.enums.HospitalEnum;
import com.qf.hospital.system.exception.HospitalEx;
import com.qf.hospital.system.vo.ResultVO;

/**
 * @author 郑大仙丶
 * @version 1.0
 * @date 2021/3/24 10:39
 */
public class R {

    public static ResultVO msg(String msg){
        ResultVO vo = new ResultVO();
        vo.setCode(0);
        vo.setMsg(msg);
        return vo;
    }


    public static ResultVO ok(Object data){
        ResultVO vo = new ResultVO();
        vo.setCode(0);
        vo.setMsg("");
        vo.setData(data);
        return vo;
    }

    public static ResultVO ok(Long count,Object data){
        ResultVO vo = new ResultVO();
        vo.setCode(0);
        vo.setMsg("");
        vo.setCount(count);
        vo.setData(data);
        return vo;
    }

    public static ResultVO ok(){
        return R.ok(null);
    }

    public static ResultVO error(HospitalEnum hospitalEnum){
        ResultVO vo = new ResultVO();
        vo.setCode(hospitalEnum.getCode());
        vo.setMsg(hospitalEnum.getMsg());
        return vo;
    }

    public static ResultVO error(HospitalEx ex){
        ResultVO vo = new ResultVO();
        vo.setCode(ex.getCode());
        vo.setMsg(ex.getMessage());
        return vo;
    }

    public static ResultVO error(Integer code,String msg){
        ResultVO vo = new ResultVO();
        vo.setCode(code);
        vo.setMsg(msg);
        return vo;
    }

}
